home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4206 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Float calculations
  5. Date: 02 Feb 1996 18:26:54 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb2112654@qcd.lanl.gov>
  8. References: <4eqssf$d9q@camelot.ccs.neu.edu> <DM458u.F1y@microunity.com>
  9.     <DM5AtL.C24@uns.bris.ac.uk>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11. Mime-Version: 1.0
  12. Content-Type: text
  13. In-reply-to: nathan@pact.srf.ac.uk's message of Fri, 2 Feb 1996 11:05:44 GMT
  14.  
  15. In article <DM5AtL.C24@uns.bris.ac.uk> nathan@pact.srf.ac.uk (Nathan
  16. Sidwell) writes: 
  17. <snip>
  18.    for instance
  19.        float a;
  20.        double b, c;
  21.  
  22.        b = 99974.0/50.0;
  23.        a = b;
  24.        c = a;
  25.  
  26.    a and b will be different (provided a's been stored), but
  27.  
  28. Actually, there is no requirement that double is more precise or in
  29. any way different than float. But most modern machines do make a
  30. distinction. 
  31.  
  32.    will c be equal to a or to b?
  33.  
  34. I believe that the standard does require c to be equal to
  35. a. Optimizations are disallowed in C if they have any visible effect,
  36. unless specifically permitted by the standard: and almost the only
  37. thing that the standard permits is to hold intermediate results _while
  38. evaluating an expression_ in higher precision. Even there, a footnote
  39. advises that the semantics of a cast and assignment would lead to
  40. truncation. In short, C is not a language in which I would like to do
  41. large scale numerical calculations.
  42.  
  43. Fortunately many compilers accept correct C code and allow me to
  44. specify (by commission or ommission) that I want the compiler to
  45. compile my code wrong in such controlled ways.
  46.  
  47. Cheers
  48. Tanmoy
  49. --
  50. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  51. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  52. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  53. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  54. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  55. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  56.